//
//  WBStatusCell.swift
//  CFZWeiBo
//
//  Created by Cedric Zheng on 29/11/2016.
//  Copyright © 2016 Cedric Zheng. All rights reserved.
//

import UIKit

class WBStatusCell: UITableViewCell {
    
    var statusViewModel: WBStatusViewModel? {
        didSet{
            originalView.statusViewModel = statusViewModel
            retweetedView.statusViewModel = statusViewModel
        }
    }

    lazy var originalView: WBOriginalView = WBOriginalView()
    
    lazy var retweetedView: WBRetweetedView = WBRetweetedView()
    
    lazy var CellToolBar: WBCellToolBar = WBCellToolBar()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

extension WBStatusCell {
    
    func setupUI() {
        backgroundColor = UIColor.lightGray
        
        contentView.addSubview(originalView)
        contentView.addSubview(retweetedView)
        contentView.addSubview(CellToolBar)
        
        originalView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(5)// Margin on top
            make.left.right.equalToSuperview()
        }
        
        retweetedView.snp.makeConstraints { (make) in
            make.top.equalTo(originalView.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
        
    }
    
}

